﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Xml.Linq;
using Tigera.LibCommon;
using System.Windows.Forms;
using Tigera.Network;

namespace Plugin.NetRiskMgr
{
    public class MQClient
    {
        static MQClient instance = new MQClient();


        MQConnection _conn;
        public string MainExchange
        {
            get
            {
                if(string.IsNullOrEmpty(_mainexchange))
                {
                    _mainexchange = GetSetting("configuration", "NetWork", "MQExchange");
                }
                return _mainexchange;
            }
        }


        string _mainexchange ;
        public MQConnection MQConn
        {
            get { return _conn; }
            set { _conn = value; }
        }

        private MQClient()
        {
            try
            {
                _cfg = new XmlFiles("Plugin.NetRiskMgr.xml");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("无法加载配置文件" + ex.ToString());
            	
            }
            _debugmode = _cfg.GetNodeValue("configuration", "debugmode") == "true";
            
        }
        XmlFiles _cfg;
        public string GetSetting(params string[] datas)
        {
            var ret = _cfg.GetNodeValue(datas);
            return ret;
        }

        public static MQClient Instance
        {
            get
            {
                return instance;                
            }            
        }
        private bool _debugmode;

        public bool Debugmode
        {
            get { return _debugmode; }
            //set { _debugmode = value; }
        }
        private bool logined;

        public bool Logined
        {
            get { return logined; }
            set { logined = value; }
        }
        public bool Login(string usr, string pwd)
        {
            return true;
        }
    }
}
